package com.osdp.home.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.LinkedList;
import java.util.List;

/**
 * 对应前端菜单形成的字段
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MenuVo implements Comparable<MenuVo>{
    private String id;

    private String parentId;

    private String name;

    private String path;

    private String component;

    private String icon;

    private Integer sortNo;

    private List<MenuVo> children = new LinkedList<>();

    @Override
    public int compareTo(MenuVo o) {
        //再按id排序
        if(this.sortNo > o.getSortNo()) {
            return 1;
        }
        if(this.sortNo < o.getSortNo()){
            return -1;
        }
        //按name排序
        if(this.name.compareTo(o.getName())>0) {
            return 1;
        }
        if(this.name.compareTo(o.getName())<0) {
            return -1;
        }
        //相等则返回0
        return 0;
    }
}
